package com.atguigu.utils;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

//线程池，用于异步IO获取phoenix维表信息
//单例：懒汉式获得线程池
public class ThreadPoolUtil {
    private static ThreadPoolExecutor threadPoolExecutor;

    public static ThreadPoolExecutor getThreadPoolExecutor(){
        if (threadPoolExecutor==null){
            synchronized (ThreadPoolExecutor.class) {
                if (threadPoolExecutor==null) {
                    threadPoolExecutor = new ThreadPoolExecutor(4, 20, 5, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
                }
            }

        }
        return threadPoolExecutor;
    }
}
